<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>
      JSqlParser - Home    </title>
    <meta http-equiv="Content-Type"
    content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content="JSqlParser, sql, database, parser, Java, sql parser, syntax, sql syntax, open-source, open source, free, Java sql parser" />
	<meta name="Description" content="Java Sql parser; parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern. Free." />
    <link href="inc/style.css" rel="stylesheet"
    type="text/css" />
  </head>
  <body>
    <div id="title">
      <img alt="JSqlParser" src="img/jsqlLogo.gif" height="63"
      width="318" />
    </div>
    <div id="menu">
				 <a href="home.php"id="current">Home</a>
<a href="example.php">Example</a>
<a href="known_issues.php">Known issues</a>
<a href="docs">Javadocs</a>
<a href="road_map.php">Road map</a>
<a href="help.php">Help</a>
<a href="http://sourceforge.net/project/showfiles.php?group_id=104597">Download</a>
<a href="http://sourceforge.net/projects/jsqlparser/">Sourceforge</a>
    </div>
    <div id="content">
				       <h3>
        What is it
      </h3>
      <p>
        JSqlParser parses an SQL statement and translate it into
        a hierarchy of Java classes.<br />
         The generated hierarchy can be navigated using the <a target="_blank"
        href="http://en.wikipedia.org/wiki/Visitor_pattern">Visitor
        Pattern</a>
      </p>
      <br />
       
      <h3>
        How it works
      </h3>
      <p>
        It is built using <a target="_blank"
        href="http://javacc.dev.java.net/">JavaCC</a>. The core
        JavaCC grammar for SQL has been taken from <a target="_blank"
        href="http://www.informatik.hu-berlin.de/~draheim/java/jjtree.html">
        Guido Draheim's site</a> and has been changed in order to
        produce a hierarchy of Java classes.
      </p>
      <br />

	<h3>Alternatives to JSqlParser?</h3>
	<p>
		<a href="http://www.sqlparser.com/gspjava.php?ref=jsqlparser">General
		SQL Parser</a> looks pretty good, with extended SQL syntax (like
		PL/SQL and T-SQL) and java + .NET APIs.
		The tool is commercial (license available online), with a free download option.
	</p>
	<br />
      <h3>
        How it can be used
      </h3>
      <p>
        The method 
        <a href="docs/net/sf/jsqlparser/parser/CCJSqlParserManager.html#parse(java.io.Reader)">CCJSqlParserManager.parse</a> 
        returns a class implementing <a href="docs/net/sf/jsqlparser/statement/Statement.html">Statement</a>
        which can be used to navigate the structure representing the SQL statement.<br />
         To avoid using the <code>instanceof</code> operator as
        in:
      </p>
<pre>
      <code>            
        if (statement instanceof Insert) {
           // insert case
        }
        else if (statement instanceof Update) {
           // update case
        }
       </code>              
</pre>
			<p>
				 the hierarchy can be accessed using proper visitors:
			</p>
<pre>
      <code>            
        void visit(Insert statement) {
           // insert case
        }
	
        void visit(Update statement) {
           // update case
        }
       </code>              
</pre>
    </div>
  </body>
</html>
